 
#include "Pch.h"
#include "ScriptBind_Node.h"
#include "Client/CoreApp.h"
#include "Client/OgRoot.h"
//------------------------------------------------------------------------
CScriptBind_Node::CScriptBind_Node( Ci::IScriptSystem * pScriptSystem, Ci::CCoreApp * pSystem )
{
	CScriptableBase::Init(pScriptSystem,pSystem);
	SetGlobalName("Node");
 
#undef SCRIPT_REG_CLASSNAME 
#define SCRIPT_REG_CLASSNAME &CScriptBind_Node::

	SCRIPT_REG_FUNC(createNode);
	SCRIPT_REG_FUNC(destoryNode);
 	SCRIPT_REG_FUNC(Attach);
	SCRIPT_REG_FUNC(Detach);
	
}
//-----------------------------------------------------------------------------
CScriptBind_Node::~CScriptBind_Node()
{
}
 
//-----------------------------------------------------------------------------
int CScriptBind_Node::createNode(IFunctionHandler *pH)
{
	//if (pH->GetParamCount() == 1)
	{
		const char* name;
		//const char* funcname;
		if(!pH->GetParam(1,name))
			m_pSS->RaiseError( "<CScriptBind_Node::createNode> parameter 1 not specified or nil (entity id to attach to)" );
		
		Ogre::SceneNode* scenenode = Ci::CCoreApp::getSingleton().getOgRoot()->getSceneMgr()->getRootSceneNode()->createChildSceneNode(name);
	}
	return pH->EndFunction();
}
//-----------------------------------------------------------------------------
int CScriptBind_Node::destoryNode(IFunctionHandler *pH)
{
	//if (pH->GetParamCount() == 2)
	{
		const char* name;
		//const char* funcname;
		if(!pH->GetParam(1,name))
			m_pSS->RaiseError( "<CScriptBind_Node::createNode> parameter 1 not specified or nil (entity id to attach to)" );

		  Ci::CCoreApp::getSingleton().getOgRoot()->getSceneMgr()->destroySceneNode(name);
	}

	return pH->EndFunction();
}

//-----------------------------------------------------------------------------
 
int CScriptBind_Node::Attach(IFunctionHandler * pH)
{



	return pH->EndFunction();
}
 //-----------------------------------------------------------------------------
int CScriptBind_Node::Detach(IFunctionHandler * pH)
{



	return pH->EndFunction();
}

//-----------------------------------------------------------------------------